home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / pvm34b3.zip / pvm34b3 / pvm3 / examples / gmbi.c < prev    next >
C/C++ Source or Header  |  1997-07-22  |  4KB  |  134 lines

  1.  
  2. static char rcsid[] =
  3.     "$Id: gmbi.c,v 1.4 1997/07/09 13:24:43 pvmsrc Exp $";
  4.  
  5. /*
  6.  *         PVM version 3.4:  Parallel Virtual Machine System
  7.  *               University of Tennessee, Knoxville TN.
  8.  *           Oak Ridge National Laboratory, Oak Ridge TN.
  9.  *                   Emory University, Atlanta GA.
  10.  *      Authors:  J. J. Dongarra, G. E. Fagg, M. Fischer
  11.  *          G. A. Geist, J. A. Kohl, R. J. Manchek, P. Mucci,
  12.  *         P. M. Papadopoulos, S. L. Scott, and V. S. Sunderam
  13.  *                   (C) 1997 All Rights Reserved
  14.  *
  15.  *                              NOTICE
  16.  *
  17.  * Permission to use, copy, modify, and distribute this software and
  18.  * its documentation for any purpose and without fee is hereby granted
  19.  * provided that the above copyright notice appear in all copies and
  20.  * that both the copyright notice and this permission notice appear in
  21.  * supporting documentation.
  22.  *
  23.  * Neither the Institutions (Emory University, Oak Ridge National
  24.  * Laboratory, and University of Tennessee) nor the Authors make any
  25.  * representations about the suitability of this software for any
  26.  * purpose.  This software is provided ``as is'' without express or
  27.  * implied warranty.
  28.  *
  29.  * PVM version 3 was funded in part by the U.S. Department of Energy,
  30.  * the National Science Foundation and the State of Tennessee.
  31.  */
  32.  
  33. /*
  34.  *    Filename:    gmbi.c    get mailbox info
  35.  *
  36.  * This program will simply grab and dump the "info" fields
  37.  * from the mailbox to display.
  38.  *
  39.  *  A regular expression <regex> is used to specify which of the
  40.  *  mailboxes to grab and display.  Note that from the command line
  41.  *  prompt the <regex> expression should be enclosed within 'single'
  42.  *  quotes so that your shell does not try to process it...
  43.  *
  44.  *  Example:  gmbi 'ra+ts'
  45.  *  Will match any ( rat ) entry that contains at least one a:
  46.  *            ie ) rats - raats - raaats - etc...
  47.  *
  48.  *  Both the unqualified  gmbi  as well as  gmbi '*'   
  49.  *  will return all mailbox entries.
  50.  *
  51.  *
  52.  *  usage: gmbi <regex>
  53.  *
  54.  *  files used:  gmbi.c taskf.c
  55.  */
  56.  
  57. #include <stdio.h>
  58. #ifndef WIN32
  59. #include <unistd.h>        /* for gethostname */
  60. #else
  61. #include "pvmwin.h"
  62. #endif
  63. #include <string.h>
  64. #include "pvm3.h"
  65.  
  66. main( argc, argv )
  67. int argc;
  68. char *argv[];
  69. {
  70.     char *me = "gmbi";
  71.     int info;                /* status of function call */
  72.     char pattern[100];        /* regular expression to search on */
  73.     int nclasses;            /* number of classes returned */
  74.  
  75.     /* pointer to pvmmboxinfo structure */
  76.     static struct pvmmboxinfo *classes
  77.             = (struct pvmmboxinfo *) NULL;
  78.  
  79.     int i, j;                /* temp integer */
  80.  
  81.     /* display_incomming_parameters( me, argc, argv ); */
  82.  
  83.     /*
  84.      *  validate input parameters
  85.      */
  86.     if ( argc == 2 ) {
  87.         /*
  88.          *  got valid data -- use it...
  89.          */
  90.         strcpy( pattern, argv[1] );        /* copy regex to local */
  91.     }
  92.     else {
  93.         /*
  94.          *  didn't get the full command line input - see if can recover?
  95.          */
  96.         if ( argc == 1 ) {
  97.             /*
  98.              *  default to retrieve all mailbox entries
  99.              */
  100.             strcpy( pattern, "*" );
  101.         }
  102.         else {
  103.             /*
  104.              *  command line input is wacked - make user try again...
  105.              */
  106.             printf( "\n\nusage: gmbi <regex>\n" );
  107.             exit( -1 );
  108.         }
  109.     } /* end_if */
  110.  
  111.     /*
  112.      *  get the mailbox information for the user specified regex 
  113.      *  pattern and display results
  114.      */
  115.     if ( (info = pvm_getmboxinfo( pattern, &nclasses, &classes )) < 0 ) {
  116.         printf( "\n\nsomething broke in pvm_getmboxinfo...\n\n" );
  117.         exit( -1 );
  118.     }
  119.     printf( "\n%s: %d mbox entries returned.", me, nclasses );
  120.     printf( "\n-------------------------------" );
  121.     for ( i=0 ; i < nclasses ; i++ ) {
  122.         printf( "\n%s: class name: <%s>", me, classes[i].mi_name );
  123.         for ( j=0 ; j < classes[i].mi_nentries ; j++ ) {
  124.             printf(
  125.             "\n\t: indices <%d>\towner_tid <t%x>\tflags <%d> = <%s>",
  126.                     classes[i].mi_indices[j], classes[i].mi_owners[j],
  127.                     classes[i].mi_flags[j],
  128.                     get_flagstring( classes[i].mi_flags[j] ) );
  129.         } /* end_for j */
  130.     } /* end_for i */
  131.     printf( "\n\n" );
  132. } /* end_main */
  133.  
  134.